home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / fido / OBManager.lha / OBManager / ARexx / db / RunHost < prev   
Text File  |  1995-12-13  |  2KB  |  112 lines

  1. /*
  2.  * RunHost
  3.  *
  4.  * USAGE: boolean = 'db/RunHost'(hostport,tags,hostargs)
  5.  *
  6.  * REQUIREMENTS:
  7.  *  rexxreqtools.library
  8.  *    REXX:dos/error
  9.  *
  10.  * RunHost let user launch the execution of any program in background
  11.  * waiting for its message port...
  12.  *
  13.  * $(C): (1995, Rocco Coluccelli, Bologna)
  14.  * $VER: RunHost 1.01 (13.Dec.1995)
  15.  */
  16.  
  17. SIGNAL ON halt
  18. SIGNAL ON break_c
  19. SIGNAL ON syntax
  20. SIGNAL ON failure
  21.  
  22. ADDRESS COMMAND
  23.  
  24. hostport = ARG(1)
  25. IF hostport = '' THEN EXIT 0
  26.  
  27. IF SHOW('P',hostport) THEN EXIT 1
  28.  
  29. nl = '0a'x
  30.  
  31. /*
  32.  *    Try to find the host in the database
  33.  */
  34. hostlist = 'REXX:db/hosts.lst'
  35.  
  36. IF OPEN('db',hostlist,'r') THEN
  37. DO
  38.     bl_sx = '/*' hostport || nl; bl_dx = nl || '*/' || nl
  39.     PARSE VALUE READCH('db',65530) WITH sx (bl_sx) hostcmd (bl_dx) dx
  40.     CALL CLOSE('db')
  41.  
  42.     IF Launch(ARG(3)) THEN EXIT 1
  43.  
  44.     /*
  45.      *    The command line is wrong, remove it from the database...
  46.      */
  47.     IF hostcmd ~= '' THEN
  48.         IF OPEN('db',hostlist,'w') THEN
  49.         DO
  50.             CALL WRITECH('db',sx || dx)
  51.             CALL CLOSE('db')
  52.         END
  53. END
  54.  
  55. /*
  56.  *    Add a new entry into the database
  57.  */
  58. lib = "rexxreqtools.library"; IF ~SHOW('L',lib) THEN CALL ADDLIB(lib,0,-30)
  59.  
  60. str.1 = 'Show host for:'
  61. str.2 = 'Edit the command line.' || nl || 'All arguments will be added at the end.'
  62. str.3 = 'Run Host'
  63.  
  64. /*
  65.  *    TAGS:
  66.  *        'opt.PUBSCR=' public screen name
  67.  */
  68. INTERPRET ARG(2)
  69.  
  70. /*
  71.  *    Tags for reqtools requesters
  72.  */
  73. CALL rtFreeFileBuffer()
  74. rt.CENTRE = 'rtez_flags=ezreqf_centertext'
  75. rt.PUBSCR = 'rt_pubscrname=' || opt.PUBSCR
  76.  
  77. /*
  78.  *    Ask for the program path
  79.  */
  80. hostpath = rtFileRequest('SYS:',,str.1 hostport,,rt.PUBSCR)
  81. IF hostpath = '' | ~EXISTS(hostpath) THEN EXIT 0
  82.  
  83. /*
  84.  *    Prepare the command line
  85.  */
  86. hostcmd = rtGetString('Run <>NIL:' hostpath,str.2,str.3,,rt.CENTRE rt.PUBSCR)
  87. IF ~Launch(ARG(3)) THEN EXIT 0
  88.  
  89. /*
  90.  *    Add line to the database
  91.  */
  92. 'Echo >>'hostlist '"/** 'hostport'*n'hostcmd'*n***/"'
  93.  
  94. EXIT 1
  95.  
  96. syntax:
  97. failure:
  98. PARSE SOURCE INFLN
  99. CALL 'dos/error'(RC,SIGL,INFLN,SOURCELINE(SIGL))
  100.  
  101. halt:
  102. break_c:
  103.     EXIT 0
  104.  
  105.  
  106. Launch:
  107.     IF hostcmd = '' THEN RETURN 0
  108.     hostcmd ARG(1)
  109.     'WaitForPort' hostport
  110.  
  111. RETURN SHOW('P',hostport)
  112.